
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class A
{
	public static void main(String[] args)
	{
		
		String content="catefirst31_localfirst1238_uptype0_20121203_icount:3";
		match(content);
		String s = "aaabb ddd  2012/05/16 bb  cc 2011/5/3 ttmm 1988/12/05 cc 1977/7/";
//		String s="<!--<base target=_blank>-><title>【58同城 58.com】成都分类信息 - 本地 免费 高效</title><meta name=Keywords content=成都分类信息,成都免费发布信息 <title>58同城</title>";
//		Pattern p = Pattern.compile("<title>(.*?)</title>");
		Pattern p = Pattern.compile("([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})");
		Matcher m = p.matcher(s);
//		String srcReg = "src=\"\\./(.*?)\"";
//		String html="src=\"./【58同城 58.com】上海分类信息 - 本地 免费 高效_files/core.php\"></";	
//		p = Pattern.compile(srcReg);
//		m = p.matcher(html.replaceAll("\\.", ""));
//		while (m.find()) {
//			System.out.println(m.group(1));
//		}
//		System.out.println(html.replaceAll("\\.", ""));
		while(m.find())
		{
			String title=m.group();
			System.out.println(m.group(1));
//			System.out.println(title.substring(7, title.indexOf("</title>")));
			System.out.println(m.group(0) + "," 
				+ m.group(1) + "," + m.group(2) + "," + m.group(3)  
				+ " at: " + m.start() + "," + m.end());
		}
		
	}
	
	
	public static void match(String content){
		Pattern p = Pattern.compile("^cate(first|second)(\\d+)_local(first|second|thirt)(\\d+)_(.*?)(\\d{8})_([iu]count:\\d+)");
//		Pattern p = Pattern.compile("^cate(first|second)(\\d+)_local(first|second|thirt)(\\d+)_(.*?)(\\d{8})_(.*)");
		Matcher m = p.matcher(content);
		if(m.find()){
		   String cateid_localid=m.group(2)+"_"+m.group(4);
		   String info=m.group(5)+m.group(7);
		   System.out.println(cateid_localid+"---------"+info);
		}
	}
	
	 public static String readFile(File file)
	    {
	        try
	        {
	            InputStreamReader read = new InputStreamReader (new FileInputStream(file)); 
	            BufferedReader bufread=new BufferedReader(read);   
	            StringBuffer sb=new StringBuffer();
	            String str="";
	            while ((str = bufread.readLine()) != null) 
	                sb.append(str+"\n");
	            String txt=new String(sb);
	            return txt;
	        }
	        catch (Exception e)
	        {
	            e.printStackTrace();
	            return null;
	        }
	    }
}